package com.alangyun.remind;

import java.util.Date;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Component;


@Component("remind-pref")
public class RemindPreference {
	
	public static final String rootContext = "/mind";	

	/** 数据根路径 * */
	private static String dataPath;
	/** 上传的根目录地址 * */
	private static String uploadRootPath;
	/** 站点访问首地址 * */
	private static String domain;
	/** 用来控制是否为Demo * */
	private static boolean demo=true;
	private static Date lastDate ;
	
	public static boolean isNormal() {		
		if(!demo)
			return true;
		else {
			return lastDate.after(new Date());
		}
		
	}

	public static String getDataPath() {
		return dataPath;
	}

	public static String getUploadRootPath() {
		return uploadRootPath;
	}

	public static String getDomain() {
		return domain;
	}
	
	@Value("${alangyun.data-path}")
	public void setDataPath(String dataPath) {
		RemindPreference.dataPath = dataPath;
	}

	@Value("${spring.servlet.multipart.location}")
	public void setUploadRootPath(String uploadRootPath) {
		RemindPreference.uploadRootPath = uploadRootPath;
	}

	@Value("${alangyun.domain:http://localhost}")
	public void setDomain(String domain) {
		RemindPreference.domain = domain;
	}

	@Value("${alangyun.cert.demo:true}")
	public void setDemo(boolean demo) {
		RemindPreference.demo = demo;
	}

	@Value("#{new java.text.SimpleDateFormat(\"yyyy-MM-dd\").parse(\"${alangyun.cert.last-date:2023-04-01}\")}")
	public void setLastDate(Date lastDate) {
		RemindPreference.lastDate = lastDate;
	}


}
